<?php

namespace app\common\model\dts\material\storage;

use think\Model;


class Log extends Model
{

    

    

    // 表名
    protected $name = 'dts_material_storage_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'category_text',
        'saving_text',
        'traceability_text',
        'qualified_text',
        'shopping_text',
        'packaging_text',
        'organoleptic_text'
    ];
    

    
    public function getCategoryList()
    {
        return ['daily' => __('Category daily'), 'expen' => __('Category expen'), 'food' => __('Category food')];
    }

    public function getSavingList()
    {
        return ['1' => __('Saving 1'), '2' => __('Saving 2'), '3' => __('Saving 3')];
    }

    public function getTraceabilityList()
    {
        return ['0' => __('Traceability 0'), '1' => __('Traceability 1')];
    }

    public function getQualifiedList()
    {
        return ['0' => __('Qualified 0'), '1' => __('Qualified 1')];
    }

    public function getShoppingList()
    {
        return ['0' => __('Shopping 0'), '1' => __('Shopping 1')];
    }

    public function getPackagingList()
    {
        return ['0' => __('Packaging 0'), '1' => __('Packaging 1')];
    }

    public function getOrganolepticList()
    {
        return ['0' => __('Organoleptic 0'), '1' => __('Organoleptic 1')];
    }


    public function getCategoryTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['category']) ? $data['category'] : '');
        $list = $this->getCategoryList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getSavingTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['saving']) ? $data['saving'] : '');
        $list = $this->getSavingList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTraceabilityTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['traceability']) ? $data['traceability'] : '');
        $list = $this->getTraceabilityList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getQualifiedTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['qualified']) ? $data['qualified'] : '');
        $list = $this->getQualifiedList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getShoppingTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['shopping']) ? $data['shopping'] : '');
        $list = $this->getShoppingList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPackagingTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['packaging']) ? $data['packaging'] : '');
        $list = $this->getPackagingList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getOrganolepticTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['organoleptic']) ? $data['organoleptic'] : '');
        $list = $this->getOrganolepticList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
